<DIV id="mainContainer">

	<DIV id="leftCol">
	</DIV>
	
	<DIV id="contentCol">
		<h1>
			Friendship Request
		</h1>

<?php                                                                                                  
if(isset($_SESSION['Accept_request']))
{
	if(isset($_GET['a'])){

		require_once('Get_friends.php');
		$F=new Friends();
		$F->Accept_friendship($_SESSION['info']['id_user'],$_SESSION['Accept_request'][$_GET['a']]);
		$_SESSION['Accept_request']=NULL;
		echo "<meta http-equiv='refresh' content='0;URL=main.php?page=friendrequest'>";
	
	}
	
		if(isset($_GET['b'])){

		require_once('Get_friends.php');
		$F=new Friends();
		$F->Ignore_friendship($_SESSION['info']['id_user'],$_SESSION['Accept_request'][$_GET['b']]);
		$_SESSION['Accept_request']=NULL;
		echo "<meta http-equiv='refresh' content='0;URL=main.php?page=friendrequest'>";
	
	}
}

$dbin = new DB();                                                                                      
$dbin->query("select u.lastname as ln, u.firstname as fn, u.id_user as iu  from friendship as f, user as u 
			where u.id_user=f.id2 and f.id1=".$_SESSION['info']['id_user']." and f.accept1=0 and f.accept2=1
			Order by ln ;");                                                        

$dbin->getrownumber();
if($dbin->nbrow==0){
		echo "No friend request at the time being. Sorry Pal !";
}else{

	echo "<DIV class='wrap'>";                                                                    
    echo 		"<DIV class='resultcontainer' style='font-weight: bold;'>";                                                                                                                                                                
	echo    		"<DIV class='result1'> Name </DIV><DIV class='result3'> Friendship </DIV>";
	echo 		"</DIV><DIV class='fbcontentdivider'></DIV>";
	        $i=1; 
		while($dbin->fetch_assoc()){
			$_SESSION['Accept_request'][$i]=$dbin->row['iu'];	
			echo "<DIV class='resultcontainer'>";   			
			echo "<DIV class='result1'>".$dbin->row['fn']." ".$dbin->row['ln']."
				</DIV><DIV class='result3'><a  class='fbtab' href='main.php?page=friendrequest&a=".$i."'> Accept</a>
				<a  class='fbtab' href='main.php?page=friendrequest&b=".$i."'> Ignore</a></DIV>";
			$i=$i+1;	
			echo "</DIV><DIV class='fbcontentdivider'></DIV>";
		}		
	echo "</DIV>";                                                                                 
}			                                                                                                       
?>                    
	</DIV>
</DIV>    
